<?php
/**
 * Created by PhpStorm.
 * User: MIS
 * Date: 2018/10/29
 * Time: 10:26
 */
namespace Admin\Controller;
use Think\Controller;
class JudgeController extends Controller
{
    public function index()
    {
        $text = M();
        $id = I("id");
        $username = I("username");
        session("tid", $id);
        $s = "select COUNT(id)  FROM ks_pd where tid='$id'";
        $count = $text->query($s);
//        var_dump($count["0"]["COUNT(id)"]);
//        exit();
        $sql = "select id,content,success FROM ks_pd where tid='$id'";
        $new_test = $text->query($sql);
        $this->assign("data", $new_test);
        $this->assign("username", $username);
        $this->assign('news_count', $count["0"]["COUNT(id)"]);
        $this->display();
    }

    public function edit($id)
    {

        redirect(U('/Admin/EditJudge/index', array('id' => $id)));
    }

    public function add()
    {

        redirect(U('/Admin/EditJudge/index'));
    }
    public function  delete($id){
        $article=M('pd');
        $a= $article->where('`id`='.$id)->delete();
        if($a){
            $this->success('该题删除成功',U('/Admin/Judge/index',array('id'=>$_SESSION["id"])));
        }else{
            $this->error('该题删除失败');
        }
    }

}